﻿package com.bn.NNYY;

/*
 * 控制背景图片变换的线程
 */

public class FishNetThread extends Thread {
	
	GameView gameview;
	private boolean Flag=false;//线程标志位
	private int sleepSpan=600;//线程休息的时间
	
	public FishNetThread(GameView gameview)//构造方法
	{
		this.gameview=gameview;
	}
	@Override
	public void run()
	{
		while(isFlag())
		{
			try
			{
				synchronized (gameview.afishnet) {
					if(gameview.afishnet.isEmpty())//如果渔网上边没有鱼
					{
						gameview.fishingnet.i=0;
						gameview.fishingnet.setFishNetIsBad(false);//设置渔网是完好的
					}else
					{
						if(gameview.fishingnet.i==6)
						{
							gameview.fishingnet.i=0;
							gameview.fishingnet.setFishNetIsBad(true);//设置渔网破损到不可以捕鱼的程度
						}else
						{
							gameview.fishingnet.i++;
							gameview.fishingnet.setFishNetIsBad(false);
						}
					}
				}
				sleep(sleepSpan);//休息50毫秒
			}catch(Exception e)
			{
				e.printStackTrace();
			}
		}		
	}
	
	public void setFlag(boolean Flag) {
		this.Flag = Flag;
	}
	public boolean isFlag() {
		return Flag;
	}
	
}
